<template>
  <div>
    <div class="back">
      <van-icon
        name="arrow-left"
        color="#ccc"
        size="20px"
        style="margin: 10px"
        @click="tap(index)"
      />
    </div>
    <div>{{id}}</div>
  </div>
</template>
   
<script setup>
import { reactive, onMounted, ref } from "vue";
import { showToast } from "vant";
import { useMainStore } from "@/pinia/store.ts";
import router from "@/router/routes";
import { useRoute } from "vue-router";
import axios from "axios";
import { getCollectionApi } from "@/request/api/home.ts";

const currentIndex = ref(0);
const mainStore = useMainStore();
const route = useRoute();
const isShowLoading = ref([]);
const value = ref("");

const tap = (index) => {
  console.log();
  router.go(-1);
};

// 获取首页编辑推荐中的id
function getQueryStringParams(url = window.location.href) {
  let queryParams = {};
  // 使用URLSearchParams解析当前页面URL中的查询字符串参数
  let urlParams = new URLSearchParams(url.split("?")[1]);
  for (const [key, value] of urlParams.entries()) {
    queryParams[key] = value;
  }
  return queryParams;
}
let id = getQueryStringParams();
console.log(id);

const getCollection = async () => {
  const res = await getCollectionApi(id);
  console.log(res.data);
};
onMounted(async () => {
  await getCollection();
  isShowLoading.value = false;
});
</script>

<style lang="scss" scoped>
.back {
  position: fixed;
}
</style>